package com.hzit.seckill.config;

import com.hzit.common.utils.IdWorker;
import com.hzit.seckill.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Configuration
@EnableAsync   // 启用异步线程
public class MyWebConfig implements WebMvcConfigurer {
	@Autowired
	private LoginInterceptor loginInteceptor;
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(loginInteceptor).addPathPatterns("/**");
	}

	@Bean
	public IdWorker idWorker(){
		return new IdWorker(1,0);
	}
}
